<?php


namespace app\admin\controller;

use app\common\controller\Backend;
use app\admin\model\Admin;
class Chartoilinve extends Backend
{
    protected $model = null;
    public function _initialize()
    {

        parent::_initialize();
        $this->model = new \app\admin\model\Chartoilinve();
    }

    /**
     * 查看
     */
    public function index()
    {
        //责任人
        $info = Admin::select();
        foreach($info as $k => $v){
            $adminData[$v['id']] = $v['nickname'];
        }
        $this->assign('adminData',$adminData);

        return $this->view->fetch();
    }

    //获取表格数据
    public function merchantAjax(){
        if($this->request->isAjax()){
            $param = $this->request->param();
            //时间
            $days = $this->model->getDaysList($param['starttime'],$param['endtime']);
            //数据
            $data = $this->model->getOilinvedataList($days,$param['admin']);
            $result['data']   = $data;
            $result['days']   = $days;
            $result['type']   = ['库存','进入','消耗'];
            echo json_encode(array('code'=>200,'data'=>$result));die();
        }else{
            $this->request->isAjax('请求错误！');
        }
    }
}